import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 12


mpl.rcParams["text.usetex"] = True

TDP = r"$\epsilon$-DP"
PDP = r"Personalized DP"
RDP = r"Repeatable DP"


def set_fig_font():
    # plt.rc("font", size=BIGGER_SIZE)  # controls default text sizes
    # plt.rc("axes", titlesize=SMALL_SIZE)  # fontsize of the axes title
    # plt.rc("axes", labelsize=MEDIUM_SIZE)  # fontsize of the x and y labels
    # plt.rc("xtick", labelsize=SMALL_SIZE)  # fontsize of the tick labels
    # plt.rc("ytick", labelsize=SMALL_SIZE)  # fontsize of the tick labels
    # plt.rc("legend", fontsize=SMALL_SIZE)  # legend fontsize
    plt.rc("figure", titlesize=BIGGER_SIZE)  # fontsize of the figure title


def rmse(truth, predictions):
    return np.sqrt(np.mean((predictions - truth) ** 2))


def mae(truth, predictions):
    return np.mean(np.abs(truth - predictions))


def mre(truth, predictions, s=10):
    return np.mean(
        np.abs(truth - predictions) / np.maximum(truth, np.full_like(truth, s))
    )
